package com.eastfair.config.controller.entitycontroller;

import com.eastfair.config.entity.DisplayLocationQuestionnaireConfig;
import com.eastfair.config.service.entityservice.DisplayLocationQuestionnaireConfigService;
import com.eastfair.core.base.R;
import com.eastfair.projectcore.vo.ConfigAttributeVO;
import io.swagger.annotations.Api;
import io.swagger.annotations.ApiOperation;
import lombok.extern.slf4j.Slf4j;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.validation.annotation.Validated;
import org.springframework.web.bind.annotation.*;

import java.util.List;

/**
 * 问卷配置控制类
 * <p>
 * Date:2021/8/7
 * Time:15:37
 *
 * @author zjn
 */
@Slf4j
@Validated
@RestController
@RequestMapping("/displayLocationQuestionnaireConfig")
@Api(value = "问卷配置控制类", tags = "问卷配置控制类")
public class DisplayLocationQuestionnaireConfigController {

    @Autowired
    private DisplayLocationQuestionnaireConfigService displayLocationQuestionnaireConfigService;

    /**
     * 获取问卷配置属性信息
     *
     * @return
     */
    @GetMapping("/getAttributes")
    @ApiOperation(value = "获取问卷配置属性信息", notes = "获取问卷配置属性信息")
    public R<List<ConfigAttributeVO>> getDisplayLocationQuestionnaireConfigAttributes() {
        return R.success(displayLocationQuestionnaireConfigService.getAttributes());
    }

    /**
     * 获取问卷配置列表
     *
     * @param displayLocationQuestionnaireConfig 问卷配置列表过滤条件
     * @return
     */
    @PostMapping("/getList")
    @ApiOperation(value = "获取问卷配置列表", notes = "获取问卷配置列表")
    public R<List<DisplayLocationQuestionnaireConfig>> getList(@RequestBody(required = false) DisplayLocationQuestionnaireConfig displayLocationQuestionnaireConfig) {
        return R.success(displayLocationQuestionnaireConfigService.getList(displayLocationQuestionnaireConfig));
    }

    /**
     * 获取问卷配置
     *
     * @param flagId 标识id
     * @return
     */
    @GetMapping("/get/{flagId}")
    @ApiOperation(value = "获取问卷配置", notes = "获取问卷配置")
    public R<DisplayLocationQuestionnaireConfig> getDisplayLocationQuestionnaireConfig(@PathVariable("flagId") Long flagId) {
        return displayLocationQuestionnaireConfigService.get(flagId);
    }

    /**
     * 新增问卷配置
     *
     * @param displayLocationQuestionnaireConfig 问卷配置实体
     * @return 是否成功
     */
    @PostMapping("/saveEntity")
    @ApiOperation(value = "新增问卷配置", notes = "新增问卷配置")
    public R<Boolean> saveEntity(@RequestBody DisplayLocationQuestionnaireConfig displayLocationQuestionnaireConfig) {
        return displayLocationQuestionnaireConfigService.saveEntity(displayLocationQuestionnaireConfig);
    }

    /**
     * 删除问卷配置
     *
     * @param flagId 问卷配置标识id
     * @return 是否成功
     */
    @DeleteMapping("/{flagId}")
    @ApiOperation(value = "删除问卷配置", notes = "删除问卷配置")
    public R<Boolean> deleteEntity(@PathVariable("flagId") Long flagId) {
        return displayLocationQuestionnaireConfigService.deleteEntity(flagId);
    }

    /**
     * 修改问卷配置信息
     *
     * @param displayLocationQuestionnaireConfig 问卷配置信息
     * @return 是否成功
     */
    @PutMapping("/updateEntity")
    @ApiOperation(value = "修改问卷配置信息", notes = "修改问卷配置信息")
    public R<Boolean> updateEntity(@RequestBody DisplayLocationQuestionnaireConfig displayLocationQuestionnaireConfig) {
        return displayLocationQuestionnaireConfigService.updateEntity(displayLocationQuestionnaireConfig);
    }

}
